<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/manage/header.jsp"%>
<div>
	
    <c:if test="${empty page.records}">
    	<h3>没有任何用户，请先添加</h3>
    	<a href="${pageContext.request.contextPath}/manage/regist.jsp">添加用户</a>
    </c:if>
     <c:if test="${!empty page.records}">
     	<table border="1" width="656">
     		<tr>
     			<th>序号</th>
     			<th>用户名</th>
     			<th>家庭住址</th>
     			<th>电话</th>
     			<th>操作</th>
     		</tr>
     		<c:forEach items="${page.records}" var="u" varStatus="vs">
     			<tr class="odd">
	     			<td>${vs.count}</td>
	     			<td>${u.username }</td>
	     			<td>${u.address }</td>
	     			<td>${u.phonenum }</td>
	     			<td>
	     			    [<a href="${pageContext.request.contextPath}/manage/regist.jsp">添加</a>]
	     				[<a href="javascript:updateOneItem('${u.id }')">修改</a>]
	     				[<a href="javascript:delOneItem('${u.id}')">删除</a>]
	     			</td>
	     		</tr>
     		</c:forEach>
     	</table>
     	<%@include file="/commons/page.jsp"%>
     </c:if>
     </div>
     
     <script type="text/javascript">
	function delOneItem(userId) {
		var sure = window.confirm("确定删除该选项？");
		if (sure) {
			window.location.href = "${pageContext.request.contextPath}/client/CilentServlet?op=delUser&userId="+ userId;
		}

	}
	function updateOneItem(userId) {
		var sure = window.confirm("确定更新此用户？");
		if (sure) {
			window.location.href = "${pageContext.request.contextPath}/client/CilentServlet?op=updateUser&userId="+ userId;
		}

	}
</script>
  </body>
</html>
